import { init, getModularity } from './getModularity.js';
import localSearch from './localSearch.js';
import getH from './getH.js';

function evaluateSOO(
  matrix,
  edgeData = init(matrix),
  obj,
  useLocalSearch,
  useLocalSearchProbability = 0,
  targetFunction,
  bestValue,
  w
) {
  let getTargetValue;
  if (targetFunction === 'H') getTargetValue = getH;
  else if (targetFunction === 'G') getTargetValue = getModularity;
  if (useLocalSearch && Math.random() < useLocalSearchProbability) {
    obj.factorialCosts[0] = localSearch(
      matrix,
      obj.rnvec,
      edgeData,
      targetFunction,
      bestValue.rnvec,
      w
    );
  } else {
    obj.factorialCosts[0] = getTargetValue(matrix, obj.rnvec, edgeData, w);
  }
}
export default evaluateSOO;
